##package cookie

window.cookie = {}

( ->

##private

  list = {}

##public

  cookie.refresh = ->
    cookies = document.cookie.split "; "
    for c in cookies
      [key, value] = c.split "="
      list[key] = value
  cookie.write = ->
    str = ""
    for k,v of list
      document.cookie = k + "=" + v
  cookie.get = (name) ->
    cookie.refresh()
    list[name]
  cookie.set = (name, value) ->
    cookie.refresh()
    list[name] = value
    cookie.write()

)()